<?php
class Api{
    static $table = "role1";
    function post($req){
        $table = self::$table;

        $total = pt\db\Mysql::init()
            ->row("select count(id) as num
                  from {$table}");
        $dataSource = pt\db\Mysql::init()
            ->rows("select *,id as `key`
                  from {$table} order by id desc");

        $columns = array(
            array(
                "title"=>"ID",
                "key"=>"id",
                "dataIndex"=>"id",
            ),
            array(
                "title"=>"名",
                "key"=>"name",
                "dataIndex"=>"name",
            ),
            array(
                "title"=>"操作",
                "key"=>"",
                "dataIndex"=>"",
            )
        );
        $res = array(
            "dataSource"=>$dataSource,
            "columns"=>$columns,
            "pagination"=>array(
                "total"=>$total['num'],
                "pageSize"=>5,
                "current"=>1,
            ),
        );
        return $res;
    }
}
